/**
 * 
 */
package net.efo.model.sqlite;

import java.sql.*;

import org.sqlite.JDBC;

/**
 * @author johnydoe
 *
 */
public class Connector {	
	private volatile static Connector con;
	private String location;
	private Statement stmt;
	
	
	private Connector(String location) throws ClassNotFoundException, SQLException {
		this.location = location;
		
		Class.forName("org.sqlite.JDBC");
		Connection connection = DriverManager.getConnection("jdbc:sqlite:"+this.location); 
		this.stmt = connection.createStatement();
	}
	
	public static Connector getInstance(String location) throws ClassNotFoundException, SQLException {
		if (con == null) {
			synchronized (Connector.class) {
				con = new Connector(location);
			}
		}
		return con;
	}
	
	public Statement getStatement() {
		return this.stmt;
	}
}
